package com.lzy.service.impl;

import com.lzy.mapper.flightMapper;
import com.lzy.pojo.flight;
import com.lzy.service.flightService;
import com.lzy.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;

public class flightServiceImpl implements flightService {
    SqlSessionFactory factory = SqlSessionFactoryUtils.getSqlSessionFactory();
    @Override
    public flight select(String flight_num) {
        SqlSession sqlSession = factory.openSession();
        flightMapper mapper = sqlSession.getMapper(flightMapper.class);
        flight flight = mapper.select(flight_num);
        sqlSession.close();
        return flight;
    }

    @Override
    public List<flight> selectAll() {
        SqlSession sqlSession = factory.openSession();
        flightMapper mapper = sqlSession.getMapper(flightMapper.class);
        List<flight> flights = mapper.selectAll();
        sqlSession.close();
        return flights;
    }
}
